$(function () {
    var markid = getUrlString('markid');
    var page = -1,totalSize = 0;
    $('.cupHref').attr('href','cupRecord.html?markid='+markid);
    //获取用户信息
    function getUserInfo() {
        getData('post','/niu/apiv3/member_userinfo.php',{'markid':markid},function (data) {
            console.log(data);
            $('#faceurl').attr('src',data.data.faceurl+'-centercrop');
            $('#nick').html(data.data.nick);

        })
    }
    getUserInfo();
    $('#goBack').click(function () {
        nativeCommand("dancool://activity=fin")
    });
    var mRefresh = new MiniRefresh({
        container: '#mrefresh', //这里是插件的容器ID
        down: {
            isAuto: false,
            callback: function () {
                // 下拉后的回调事件 ，你可以在这里执行你的后台请求数据函数，达到刷新数据的作用
                $('#recordList').empty();//清空容器
                totalSize = 0;
                page = -1;
                mRefresh.endDownLoading();
            }
        }
        ,
        up: {
            isAuto: true,
            callback: function () {
                // 向上拉后的回调事件
                page += 1;
                recordList(page)
            }
        }
    });

    function recordList(page) {
        var data = {
            'markid':markid,
            'page':page
        };
        getData('post','/niu/apiv4/niu_hongbao_isread.php',data,function (data) {
            console.log(data);
            if(data.resultcode == 200 ){
                var append = '';
                $(data.info).each(function () {
                    append += '<li>' +
                        '                    <p>'+this.reason+'</p>' +
                        '                    <p>' +
                        '                        <span>'+this.time+'</span>' ;
                    if((this.money4).substring(1) > 0){
                        append +=  '                        <span style="color:#4BD130">'+this.money4+'</span>' +
                            '                    </p>' +
                            '                </li>'
                    }else{
                        append +='                        <span>- '+this.money4+'</span>' +
                            '                    </p>' +
                            '                </li>'
                    }


                });
                $('#recordList').append(append);
                //总条数
                totalSize = totalSize + data.pagesize;
                if (totalSize > data.datacount)
                    mRefresh.endUpLoading(true);
                else{
                    mRefresh.endUpLoading(false);
                }
            }else {
                laymsg(data.msg)
            }
        })
    }

});
